package com.soso.j.spider.queue.api.impl;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.soso.core.queue.Task;

public class TaskQueue {
	private volatile static TaskQueue taskQueue=null;
	private static ExecutorService queue = Executors.newFixedThreadPool(20);
	private TaskQueue(){
	}
	public static TaskQueue getInstance(){
		if(taskQueue==null){
			synchronized (TaskQueue.class) {
				if(taskQueue==null){
					taskQueue=new TaskQueue();
				}
			}
		}
		return taskQueue;
	}
	
	public void add(final Task task){
		queue.execute(new TaskExecutor(task));
	}
}
